package com.fingard.dsp.localdb.dbtable;

import java.sql.Connection;
import java.sql.SQLException;

import com.fingard.FGBiz;
import com.fingard.db.JDBCHelper;
import com.fingard.dsp.localdb.PartitionTable;

/**渠道通知相关表*/
public class TableNotice {
	
	public static String getTableName(String pBankCode){
		String tabName = "ntc_sp_" + pBankCode;
		return tabName.toUpperCase();
	}

	/**单笔支付类通知
	 * @throws SQLException */
	public void initTableSinglePayNotice(Connection pConn, String pBankCode) throws SQLException{
		String tabName = getTableName(pBankCode);
		if(!PartitionTable.isExistTable(pConn, tabName)){
    		String sqlcreate = "CREATE TABLE "+tabName+"("+
    				"REQSEQID VARCHAR(64) PRIMARY KEY NOT NULL," +//支付流水号
    				"TRANSSTATE VARCHAR(64) NOT NULL," +//状态码
    				"PAYINFOCODE VARCHAR(128)," +//信息码
    				"PAYINFO VARCHAR(256)," +//支付信息
    				"OUTTRANSID VARCHAR(64)," +//银行流水号
    				"TRANSAMT VARCHAR(32)," +//金额
    				"BANKFRONTCODE VARCHAR(32) NOT NULL,"+//前置机代码
    				"DIGEST VARCHAR(64) NOT NULL,"+//摘要
    				"KEYVER INTEGER NOT NULL,"+//密钥版本
					"CREATEDON DATE NOT NULL," +
					"LASTMODIFIEDON DATE NOT NULL," +
					"ROWVERSION INTEGER NOT NULL);\r\n" +
					"CREATE INDEX IX1"+tabName+" ON "+tabName+" (REQSEQID);\r\n" +
					"CREATE INDEX IX2"+tabName+" ON "+tabName+" (LASTMODIFIEDON);\r\n";
    		FGBiz.logTrace.info("PartitionTable", sqlcreate);
			JDBCHelper.update(pConn, sqlcreate, null);
		}
	}
}
